// import request from '@/utils/request'
import { httpReqeustApi } from '/@/api/linxyun/base/index.ts';
import lxy_event from './lxy_page_event.js';
import Lxy_params_mgr from './lxy_params_mgr.js';
const httpRequest = httpReqeustApi();

class Lxy_page_event_emit extends lxy_event {
	constructor(e) {
		super(e);
		this.init(e);
	}

	init(e) {
		this.cfg = e;
	}

	async callEvent(expParams, rowIndex = -1) {
		// params: Lxy_params_mgr 对象;
		const inputParams = this.calcInputParams(rowIndex);
		if (inputParams === undefined || inputParams === Number.NaN) {
			return null;
		}

		// let url = this._domain + this._uri;
		// 调用远程方法;
		const { interfaceName } = this.cfg;
		const requestRes = await httpRequest.SyncPost(interfaceName, null, inputParams);
		// const requestRes = await request({
		// 	url: interfaceName,
		// 	method: 'post',
		// 	params: inputParams
		// })
		console.log(requestRes);
		return requestRes;
	}
	cb(result, params) {
		const srcData = new Lxy_params_mgr();
		srcData._params = result;
		this.calcParams(this._output_params_define, srcData, params._params);
	}
}

export default Lxy_page_event_emit;
